﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.malls.MarketUI.view {
    import flash.events.*;
    import flash.display.*;
    import Mechanics.GameMechanicInterfaces.*;
    import flash.utils.*;
    import org.aswing.*;
    import Classes.*;
    import Classes.util.*;
    import Display.*;
    import Classes.gates.*;
    import Display.aswingui.*;
    import Display.GridlistUI.model.*;
    import Display.aswingui.buttonui.*;

    public class MallCrewableCellView extends MallCellView {

        protected var m_footAlignPanel:JPanel;
        protected var m_btnAction:JButton;
        private var m_btnActionTxt:String;
        protected var m_btnAction2:JButton;
        private var m_btnAction2Txt:String;

        public function MallCrewableCellView(_arg1:IMechanicUser, _arg2:int){
            super(_arg1, _arg2, 0);
            this.m_btnActionTxt = TextFieldUtil.formatSmallCapsString(ZLoc.t("Dialogs", "Ask"));
            this.m_btnAction2Txt = TextFieldUtil.formatSmallCapsString(String(CrewGate.getCrewCost((_arg1 as MechanicMapResource).getItemName(), "storage")));
            this.m_footAlignPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            this.m_btnAction = new CustomButton();
            this.m_btnAction2 = new CustomButton();
        }
        protected function get cashButtonAsset():DisplayObject{
            return (m_assetDict["iconCash"]);
        }
        override public function makeAssets(_arg1:Dictionary):void{
            super.makeAssets(_arg1);
            var _local2:DisplayObject = _arg1[DelayedAssetLoader.MALL_ASSETS];
            m_assetDict["bg"] = (new (_local2["mall_card_staff"])() as DisplayObject);
            var _local3:DisplayObject = _arg1[DelayedAssetLoader.MARKET_ASSETS];
            m_assetDict["iconCash"] = (new (_local3["cash"])() as DisplayObject);
        }
        override public function updateView(_arg1):void{
            this.m_btnAction.setText(this.m_btnActionTxt);
            this.m_btnAction.setUI(new CoinsButtonUI());
            var _local2:ASFont = this.m_btnAction.getFont();
            this.m_btnAction.setFont(_local2.changeSize(TextFieldUtil.getLocaleFontSizeByRatio(_local2.getSize(), 1, [{
                locale:"de",
                ratio:0.8
            }, {
                locale:"id",
                ratio:0.75
            }, {
                locale:"es",
                ratio:0.9
            }, {
                locale:"fr",
                ratio:0.8
            }, {
                locale:"it",
                ratio:0.8
            }, {
                locale:"pt",
                ratio:0.9
            }, {
                locale:"tr",
                ratio:0.8
            }])));
            this.m_btnAction2.setText(this.m_btnAction2Txt);
            this.m_btnAction2.setUI(new CashButtonUI());
            this.m_btnAction2.setIcon(new AssetIcon(this.cashButtonAsset));
            this.m_btnAction2.addEventListener(MouseEvent.CLICK, this.onAltActionClick, false, 0, true);
            ASwingHelper.prepare(this);
        }
        override protected function initLayout():void{
            super.initLayout();
            ASwingHelper.setEasyBorder(this.m_btnAction, 3, 0, 0, 0);
            ASwingHelper.setEasyBorder(this.m_btnAction2, 1, 0, 0, 0);
            if (m_footPanel){
                this.m_footAlignPanel.append(this.m_btnAction);
                this.m_footAlignPanel.append(this.m_btnAction2);
                m_footPanel.append(this.m_footAlignPanel);
            };
            ASwingHelper.setEasyBorder(m_panel, 0, 13, 0);
        }
        override protected function createContentPlaceholder():DisplayObject{
            return (new Sprite());
        }
        override protected function onClick(_arg1:MouseEvent=null):void{
            _arg1.stopPropagation();
            _arg1.stopImmediatePropagation();
            this.dispatchEvent(new ViewActionEvent("onAskCrew"));
        }
        protected function onAltActionClick(_arg1:MouseEvent=null):void{
            _arg1.stopPropagation();
            _arg1.stopImmediatePropagation();
            this.dispatchEvent(new ViewActionEvent("onBuyCrew"));
        }
        override protected function onRollOver(_arg1:MouseEvent=null):void{
            this.dispatchEvent(new ViewActionEvent("onDisplayCrewableCellTooltip"));
        }
        override protected function onRollOut(_arg1:MouseEvent=null):void{
            dispatchEvent(new Event("turnOffToolTip", true));
        }

    }
}//package Modules.malls.MarketUI.view 
